Skip to content

feat(Toast): allow action without dismissing toast#2673

Open
yan-ad wants to merge 2 commits into
unovue:v2from
yan-ad:fix/toast-action-optional-close
Open

feat(Toast): allow action without dismissing toast#2673
yan-ad wants to merge 2 commits into
unovue:v2from
yan-ad:fix/toast-action-optional-close

Conversation

@yan-ad

@yan-ad yan-ad commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Resolves #2626

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Adds a closeOnClick prop to ToastAction so action buttons can run without always dismissing their toast. The default remains true, preserving the existing dismiss-on-click behavior.

This also documents the new prop and adds a regression test covering closeOnClick: false keeping the toast open after clicking the action.

📸 Screenshots (if appropriate)

N/A

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • New Features

    • Added a closeOnClick prop for toast actions to control whether the toast dismisses when an action is clicked.
  • Changes

    • ToastAction now renders as a button by default.
  • Documentation

    • Updated Toast docs with a Vue example, clarified action dismissal and keyboard behavior.
  • Tests

    • Added a test verifying actions can keep a toast open when closeOnClick is false.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b2e86813-50cb-41d6-9183-118c5940aabf

📥 Commits

Reviewing files that changed from the base of the PR and between 0446c76 and 682efb7.

📒 Files selected for processing (1)
  • docs/content/docs/components/toast.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/content/docs/components/toast.md

📝 Walkthrough

Walkthrough

This PR adds a closeOnClick prop to ToastAction to optionally prevent toast dismissal when an action is clicked. By default (closeOnClick={true}), the existing behavior is preserved. When closeOnClick={false}, the action runs without closing the toast.

Changes

ToastAction closeOnClick feature

Layer / File(s) Summary
ToastAction prop and conditional rendering
packages/core/src/Toast/ToastAction.vue, docs/content/meta/ToastAction.md
ToastAction declares an optional closeOnClick?: boolean prop (default true). The template conditionally renders ToastClose when closeOnClick is enabled; otherwise it renders a Primitive directly with conditional type="button". Component metadata documents the new prop and updates the default as element from "div" to "button".
Test coverage and user guide
packages/core/src/Toast/Toast.test.ts, docs/content/docs/components/toast.md
ToastWithPersistentAction test component renders a toast with closeOnClick: false, and a test verifies clicking the action increments a counter without closing the toast. A new Vue example in the user guide demonstrates using :close-on-click="false" with a retry action handler.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A toast that won't dismiss,
When actions call upon the kiss,
Persist and dance, no longer shy—
Let handlers run and by they fly! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main feature being added: allowing toast actions to work without automatically dismissing the toast.
Linked Issues check ✅ Passed The pull request fully addresses the primary objective from issue #2626: adding an option to prevent automatic toast closing when action buttons are clicked.
Out of Scope Changes check ✅ Passed All changes are directly related to the core feature: the new closeOnClick prop, conditional rendering logic, documentation updates, and test coverage for the feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Jun 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/reka-ui@2673

commit: 682efb7

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/content/docs/components/toast.md`:
- Around line 142-154: The keyboard-interaction docs incorrectly state that
ToastAction always closes on Space/Enter; update the keyboard table and any
related text to qualify that closing on Space/Enter is conditional on the prop
closeOnClick being true. Locate mentions of ToastAction and the keyboard table
in this doc (references: ToastAction, closeOnClick) and change the wording to
something like "closes on Space/Enter when closeOnClick === true" or equivalent
concise phrasing so the docs consistently reflect the conditional behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d67d0a50-1ec0-455c-a938-42671e607cc2

📥 Commits

Reviewing files that changed from the base of the PR and between 091d650 and 0446c76.

📒 Files selected for processing (4)
  • docs/content/docs/components/toast.md
  • docs/content/meta/ToastAction.md
  • packages/core/src/Toast/Toast.test.ts
  • packages/core/src/Toast/ToastAction.vue

Comment thread docs/content/docs/components/toast.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Action button should not always close Toast

1 participant